
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>网页版五子棋游戏</title>
    <meta name="description" content="网页版五子棋 / 404 小游戏 / FUYEOR.COM" />
	<link href="reset.css" rel="stylesheet">
	<script src="js/CookieHandle.min.js"></script>
	<script src="jquery/jquery-1.7.2.min.js"></script>
    <script>window.jQuery||document.write('<script src="js/jquery-1.7.2.js"><\/script>')</script>
<style>/*RESET STYLESHEET*/html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline}:focus{outline:0}body{line-height:1;color:black;background:#e0e3e9}ol,ul{list-style:none}table{border-collapse:separate;border-spacing:0}caption,th,td{text-align:left;font-weight:normal}blockquote:before,blockquote:after,q:before,q:after{content:""}blockquote,q{quotes:"" ""}input{vertical-align:middle}img{display:block}/*content*/.wrapper{width:800px;position:relative;margin:0 auto;top:80px;margin-bottom:32px}div.chessboard{margin:30px 0 0 0;width:542px;background:url("images/chessboard.png") no-repeat 14px 14px rgb(250,250,250);overflow:hidden;border-radius:6px}div.chessboard div{float:left;width:36px;height:36px;border-top:0px solid #ccc;border-left:0px solid #ccc;border-right:0;border-bottom:0;cursor:pointer}div.chessboard div.black{background:url("images/black.png") no-repeat 4px 4px}div.chessboard div.white{background:url("images/white.png") no-repeat 4px 4px}div.chessboard div.hover{background:url("images/hover.png") no-repeat 1px 1px}div.chessboard div.hover-up{background:url("images/hover_up.png") no-repeat 1px 1px}div.chessboard div.hover-down{background:url("images/hover_down.png") no-repeat 1px 1px}div.chessboard div.hover-up-left{background:url("images/hover_up_left.png") no-repeat 1px 1px}div.chessboard div.hover-up-right{background:url("images/hover_up_right.png") no-repeat 1px 1px}div.chessboard div.hover-left{background:url("images/hover_left.png") no-repeat 1px 1px}div.chessboard div.hover-right{background:url("images/hover_right.png") no-repeat 1px 1px}div.chessboard div.hover-down-left{background:url("images/hover_down_left.png") no-repeat 1px 1px}div.chessboard div.hover-down-right{background:url("images/hover_down_right.png") no-repeat 1px 1px}div.chessboard div.white-last{background:url("images/white_last.png") no-repeat 4px 4px}div.chessboard div.black-last{background:url("images/black_last.png") no-repeat 4px 4px}div.operating-panel{position:absolute;left:600px;top:150px;width:220px;text-align:center}.operating-panel a{display:inline-block;padding:10px 15px;margin-bottom:39px;margin-right:8px;margin-left:8px;text-decoration:none;background:#f6f6f6;border-radius:2px;color:#444;font-weight:bold;font-size:18px;font-family:"微软雅黑",Sans-serif}.operating-panel a:hover{color:#29F}.operating-panel a.disable,.operating-panel a.disable:hover{cursor:default;background:rgb(193 198 207);color:rgb(130,139,148)}.operating-panel a.selected{color:#0066ff}.operating-panel a.selected:before{content:" ";background-image:url();background-repeat:no-repeat;background-size:15px;padding:14px 10px 14px 10px;background-position:10% 50%}#result_tips{color:#CE4242;font-size:26px;font-family:"微软雅黑"}#result_info{margin-bottom:26px}#gengduo{margin-top:54px;position:absolute;left:620px;top:450px;width:180px;text-align:center}#gengduo a{display:inline-block;padding:10px 15px;margin-bottom:39px;margin-right:8px;margin-left:8px;background:rgb(100,167,233);text-decoration:none;color:#333;font-weight:bold;font-size:16px;font-family:"微软雅黑","宋体"}#gengduo a:hover{background:rgb(48,148,247);text-decoration:none}#footr{text-align:center;margin:28px auto;font-size:12px;color:#000}@media(max-width:768px){.wrapper{width:100%;margin:0 auto;top:80px;margin-bottom:32px}div.chessboard{margin:0 auto;width:542px;border-radius:0px}div.operating-panel{left:200px;margin:0 auto;top:600px;width:220px;text-align:center}}</style>
</head>
<body style="text-align: center">
<div class="wrapper">
	<div class="chessboard">
		<!-- top line -->
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top"></div>
		<div class="chess-top chess-right"></div>
		<!-- line 1 -->
		<div class="chess-left"></div>		
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 2 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 3 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 4 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 5 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 6 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 7 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 8 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 9 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 10 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 11 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 12 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- line 13 -->
		<div class="chess-left"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-middle"></div>
		<div class="chess-right"></div>
		<!-- bottom line  -->
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom"></div>
		<div class="chess-bottom chess-right"></div>
	</div>

	<div class="operating-panel">
		<p>
			<a id="black_btn" class="btn selected" href="#">黑&nbsp;棋</a>
			<a id="white_btn" class="btn" href="#">白&nbsp;棋</a>
		</p>
		<p>
			<a id="first_move_btn" class="btn selected" href="#">先&nbsp;手</a>
			<a id="second_move_btn" class="btn" href="#">后&nbsp;手</a>
		</p>
		<a id="replay_btn" class="btn" href="#">开&nbsp;&nbsp;始</a>
		<p id="result_info">胜率：100%</p>
		<p id="result_tips"></p>
	</div>
	<div style="display: none">
		<!-- 图片需合并 减少http请求数 -->
		<img src="images/black.png" alt="preload" />
		<img src="images/white.png" alt="preload" />
		<img src="images/hover.png" alt="preload" />
		<img src="images/hover_up.png" alt="preload" />
		<img src="images/hover_down.png" alt="preload" />
		<img src="images/hover_up_left.png" alt="preload" />
		<img src="images/hover_up_right.png" alt="preload" />
		<img src="images/hover_left.png" alt="preload" />
		<img src="images/hover_right.png" alt="preload" />
		<img src="images/hover_down_left.png" alt="preload" />
		<img src="images/hover_down_right.png" alt="preload" />
		<img src="images/black_last.png" alt="preload" />
		<img src="images/white_last.png" alt="preload" />
	</div>
</div>

<script>$(document).ready(function(){fiveChess.init()});var fiveChess={NO_CHESS:0,BLACK_CHESS:-1,WHITE_CHESS:1,chessArr:[],chessBoardHtml:"",humanPlayer:"black",AIPlayer:"white",isPlayerTurn:true,totalGames:cookieHandle.getCookie("totalGames")||0,winGames:cookieHandle.getCookie("winGames")||0,isGameStart:false,isGameOver:false,playerLastChess:[],AILastChess:[],init:function(){this.chessBoardHtml=$("div.chessboard").html();var _fiveChess=this;$(".operating-panel a").click(function(event){event.preventDefault();var id=$(this).attr("id");if(_fiveChess.isGameStart&&id!=="replay_btn"){return}switch(id){case"black_btn":_fiveChess.humanPlayer="black";_fiveChess.AIPlayer="white";break;case"white_btn":_fiveChess.humanPlayer="white";_fiveChess.AIPlayer="black";break;case"first_move_btn":_fiveChess.isPlayerTurn=true;break;case"second_move_btn":_fiveChess.isPlayerTurn=false;break;case"replay_btn":_fiveChess.resetChessBoard();if(_fiveChess.isGameStart){_fiveChess.gameOver()}else{_fiveChess.gameStart()}break}if(id!=="replay_btn"){$(this).addClass("selected").siblings().removeClass("selected")}});this.resetChessBoard();$("#result_info").html("胜率："+(this.winGames*100/this.totalGames|0)+"%")},resetChessBoard:function(){$("div.chessboard").html(this.chessBoardHtml);$("#result_tips").html("");this.isGameOver=false;this.isPlayerTurn=$("#first_move_btn").hasClass("selected");var i,j;for(i=0;i<15;i++){this.chessArr[i]=[];for(j=0;j<15;j++){this.chessArr[i][j]=this.NO_CHESS}}var _fiveChess=this;$("div.chessboard div").click(function(){if(!_fiveChess.isPlayerTurn||_fiveChess.isGameOver){return}if(!_fiveChess.isGameStart){_fiveChess.gameStart()}var index=$(this).index(),i=index/15|0,j=index%15;if(_fiveChess.chessArr[i][j]===_fiveChess.NO_CHESS){_fiveChess.playChess(i,j,_fiveChess.humanPlayer);if(i===0&&j===0){$(this).removeClass("hover-up-left")}else if(i===0&&j===14){$(this).removeClass("hover-up-right")}else if(i===14&&j===0){$(this).removeClass("hover-down-left")}else if(i===14&&j===14){$(this).removeClass("hover-down-right")}else if(i===0){$(this).removeClass("hover-up")}else if(i===14){$(this).removeClass("hover-down")}else if(j===0){$(this).removeClass("hover-left")}else if(j===14){$(this).removeClass("hover-right")}else{$(this).removeClass("hover")}_fiveChess.playerLastChess=[i,j];_fiveChess.playerWinOrNot(i,j)}});$("div.chessboard div").hover(function(){if(!_fiveChess.isPlayerTurn||_fiveChess.isGameOver){return}var index=$(this).index(),i=index/15|0,j=index%15;if(_fiveChess.chessArr[i][j]===_fiveChess.NO_CHESS){if(i===0&&j===0){$(this).addClass("hover-up-left")}else if(i===0&&j===14){$(this).addClass("hover-up-right")}else if(i===14&&j===0){$(this).addClass("hover-down-left")}else if(i===14&&j===14){$(this).addClass("hover-down-right")}else if(i===0){$(this).addClass("hover-up")}else if(i===14){$(this).addClass("hover-down")}else if(j===0){$(this).addClass("hover-left")}else if(j===14){$(this).addClass("hover-right")}else{$(this).addClass("hover")}}},function(){if(!_fiveChess.isPlayerTurn||_fiveChess.isGameOver){return}var index=$(this).index(),i=index/15|0,j=index%15;if(i===0&&j===0){$(this).removeClass("hover-up-left")}else if(i===0&&j===14){$(this).removeClass("hover-up-right")}else if(i===14&&j===0){$(this).removeClass("hover-down-left")}else if(i===14&&j===14){$(this).removeClass("hover-down-right")}else if(i===0){$(this).removeClass("hover-up")}else if(i===14){$(this).removeClass("hover-down")}else if(j===0){$(this).removeClass("hover-left")}else if(j===14){$(this).removeClass("hover-right")}else{$(this).removeClass("hover")}})},gameStart:function(){this.totalGames++;cookieHandle.setCookie({name:"totalGames",value:this.totalGames,expiresHours:365*24});if(!this.isPlayerTurn){this.AImoveChess()}this.isGameStart=true;$(".operating-panel p a").addClass("disable");$("#replay_btn").html("重&nbsp;&nbsp;&nbsp;玩")},gameOver:function(){this.isGameStart=false;$(".operating-panel a").removeClass("disable");$("#replay_btn").html("开&nbsp;&nbsp;&nbsp;始");$("#result_info").html("胜率："+(this.winGames*100/this.totalGames|0)+"%")},playChess:function(i,j,color){this.chessArr[i][j]=color==="black"?this.BLACK_CHESS:this.WHITE_CHESS;if(color===this.AIPlayer){$("div.chessboard div."+color+"-last").addClass(color).removeClass(color+"-last");$("div.chessboard div:eq("+(i*15+j)+")").addClass(color+"-last")}else{$("div.chessboard div:eq("+(i*15+j)+")").addClass(color)}},playerWinOrNot:function(i,j){var nums=1,chessColor=this.humanPlayer==="black"?this.BLACK_CHESS:this.WHITE_CHESS,m,n;for(m=j-1;m>=0;m--){if(this.chessArr[i][m]===chessColor){nums++}else{break}}for(m=j+1;m<15;m++){if(this.chessArr[i][m]===chessColor){nums++}else{break}}if(nums>=5){this.playerWin();return}else{nums=1}for(m=i-1;m>=0;m--){if(this.chessArr[m][j]===chessColor){nums++}else{break}}for(m=i+1;m<15;m++){if(this.chessArr[m][j]===chessColor){nums++}else{break}}if(nums>=5){this.playerWin();return}else{nums=1}for(m=i-1,n=j-1;m>=0&&n>=0;m--,n--){if(this.chessArr[m][n]===chessColor){nums++}else{break}}for(m=i+1,n=j+1;m<15&&n<15;m++,n++){if(this.chessArr[m][n]===chessColor){nums++}else{break}}if(nums>=5){this.playerWin();return}else{nums=1}for(m=i-1,n=j+1;m>=0&&n<15;m--,n++){if(this.chessArr[m][n]===chessColor){nums++}else{break}}for(m=i+1,n=j-1;m<15&&n>=0;m++,n--){if(this.chessArr[m][n]===chessColor){nums++}else{break}}if(nums>=5){this.playerWin();return}this.AImoveChess()},playerWin:function(){this.winGames++;cookieHandle.setCookie({name:"winGames",value:this.winGames,expiresHours:365*24});this.showResult(true);this.gameOver()},AImoveChess:function(){this.isPlayerTurn=false;var maxX=0,maxY=0,maxWeight=0,i,j,tem;for(i=14;i>=0;i--){for(j=14;j>=0;j--){if(this.chessArr[i][j]!==this.NO_CHESS){continue}tem=this.computeWeight(i,j);if(tem>maxWeight){maxWeight=tem;maxX=i;maxY=j}}}this.playChess(maxX,maxY,this.AIPlayer);this.AILastChess=[maxX,maxY];if((maxWeight>=100000&&maxWeight<250000)||(maxWeight>=500000)){this.showResult(false);this.gameOver()}else{this.isPlayerTurn=true}},showResult:function(isPlayerWin){if(isPlayerWin){$("#result_tips").html("恭喜你获胜啦！")}else{$("#result_tips").html("蛤蛤蛤你输咯！")}this.isGameOver=true;this.showWinChesses(isPlayerWin)},showWinChesses:function(isPlayerWin){var nums=1,lineChess=[],i,j,chessColor,m,n;if(isPlayerWin){chessColor=this.humanPlayer==="black"?this.BLACK_CHESS:this.WHITE_CHESS;i=this.playerLastChess[0];j=this.playerLastChess[1]}else{chessColor=this.AIPlayer==="black"?this.BLACK_CHESS:this.WHITE_CHESS;i=this.AILastChess[0];j=this.AILastChess[1]}$("div.chessboard div."+this.AIPlayer+"-last").addClass(this.AIPlayer).removeClass(this.AIPlayer+"-last");lineChess[0]=[i];lineChess[1]=[j];for(m=j-1;m>=0;m--){if(this.chessArr[i][m]===chessColor){lineChess[0][nums]=i;lineChess[1][nums]=m;nums++}else{break}}for(m=j+1;m<15;m++){if(this.chessArr[i][m]===chessColor){lineChess[0][nums]=i;lineChess[1][nums]=m;nums++}else{break}}if(nums>=5){for(k=nums-1;k>=0;k--){this.markChess(lineChess[0][k]*15+lineChess[1][k],isPlayerWin?this.humanPlayer:this.AIPlayer)}return}nums=1;lineChess[0]=[i];lineChess[1]=[j];for(m=i-1;m>=0;m--){if(this.chessArr[m][j]===chessColor){lineChess[0][nums]=m;lineChess[1][nums]=j;nums++}else{break}}for(m=i+1;m<15;m++){if(this.chessArr[m][j]===chessColor){lineChess[0][nums]=m;lineChess[1][nums]=j;nums++}else{break}}if(nums>=5){for(k=nums-1;k>=0;k--){this.markChess(lineChess[0][k]*15+lineChess[1][k],isPlayerWin?this.humanPlayer:this.AIPlayer)}return}nums=1;lineChess[0]=[i];lineChess[1]=[j];for(m=i-1,n=j-1;m>=0&&n>=0;m--,n--){if(this.chessArr[m][n]===chessColor){lineChess[0][nums]=m;lineChess[1][nums]=n;nums++}else{break}}for(m=i+1,n=j+1;m<15&&n<15;m++,n++){if(this.chessArr[m][n]===chessColor){lineChess[0][nums]=m;lineChess[1][nums]=n;nums++}else{break}}if(nums>=5){for(k=nums-1;k>=0;k--){this.markChess(lineChess[0][k]*15+lineChess[1][k],isPlayerWin?this.humanPlayer:this.AIPlayer)}return}nums=1;lineChess[0]=[i];lineChess[1]=[j];for(m=i-1,n=j+1;m>=0&&n<15;m--,n++){if(this.chessArr[m][n]===chessColor){lineChess[0][nums]=m;lineChess[1][nums]=n;nums++}else{break}}for(m=i+1,n=j-1;m<15&&n>=0;m++,n--){if(this.chessArr[m][n]===chessColor){lineChess[0][nums]=m;lineChess[1][nums]=n;nums++}else{break}}if(nums>=5){for(k=nums-1;k>=0;k--){this.markChess(lineChess[0][k]*15+lineChess[1][k],isPlayerWin?this.humanPlayer:this.AIPlayer)}}},markChess:function(pos,color){$("div.chessboard div:eq("+pos+")").removeClass(color).addClass(color+"-last")},putDirectX:function(i,j,chessColor){var m,n,nums=1,side1=false,side2=false;for(m=j-1;m>=0;m--){if(this.chessArr[i][m]===chessColor){nums++}else{if(this.chessArr[i][m]===this.NO_CHESS){side1=true}break}}for(m=j+1;m<15;m++){if(this.chessArr[i][m]===chessColor){nums++}else{if(this.chessArr[i][m]===this.NO_CHESS){side2=true}break}}return{"nums":nums,"side1":side1,"side2":side2}},putDirectY:function(i,j,chessColor){var m,n,nums=1,side1=false,side2=false;for(m=i-1;m>=0;m--){if(this.chessArr[m][j]===chessColor){nums++}else{if(this.chessArr[m][j]===this.NO_CHESS){side1=true}break}}for(m=i+1;m<15;m++){if(this.chessArr[m][j]===chessColor){nums++}else{if(this.chessArr[m][j]===this.NO_CHESS){side2=true}break}}return{"nums":nums,"side1":side1,"side2":side2}},putDirectXY:function(i,j,chessColor){var m,n,nums=1,side1=false,side2=false;for(m=i-1,n=j-1;m>=0&&n>=0;m--,n--){if(this.chessArr[m][n]===chessColor){nums++}else{if(this.chessArr[m][n]===this.NO_CHESS){side1=true}break}}for(m=i+1,n=j+1;m<15&&n<15;m++,n++){if(this.chessArr[m][n]===chessColor){nums++}else{if(this.chessArr[m][n]===this.NO_CHESS){side2=true}break}}return{"nums":nums,"side1":side1,"side2":side2}},putDirectYX:function(i,j,chessColor){var m,n,nums=1,side1=false,side2=false;for(m=i-1,n=j+1;m>=0&&n<15;m--,n++){if(this.chessArr[m][n]===chessColor){nums++}else{if(this.chessArr[m][n]===this.NO_CHESS){side1=true}break}}for(m=i+1,n=j-1;m<15&&n>=0;m++,n--){if(this.chessArr[m][n]===chessColor){nums++}else{if(this.chessArr[m][n]===this.NO_CHESS){side2=true}break}}return{"nums":nums,"side1":side1,"side2":side2}},computeWeight:function(i,j){var weight=14-(Math.abs(i-7)+Math.abs(j-7)),pointInfo={},chessColor=this.AIPlayer==="black"?this.BLACK_CHESS:this.WHITE_CHESS;pointInfo=this.putDirectX(i,j,chessColor);weight+=this.weightStatus(pointInfo.nums,pointInfo.side1,pointInfo.side2,true);pointInfo=this.putDirectX(i,j,-chessColor);weight+=this.weightStatus(pointInfo.nums,pointInfo.side1,pointInfo.side2,false);pointInfo=this.putDirectY(i,j,chessColor);weight+=this.weightStatus(pointInfo.nums,pointInfo.side1,pointInfo.side2,true);pointInfo=this.putDirectY(i,j,-chessColor);weight+=this.weightStatus(pointInfo.nums,pointInfo.side1,pointInfo.side2,false);pointInfo=this.putDirectXY(i,j,chessColor);weight+=this.weightStatus(pointInfo.nums,pointInfo.side1,pointInfo.side2,true);pointInfo=this.putDirectXY(i,j,-chessColor);weight+=this.weightStatus(pointInfo.nums,pointInfo.side1,pointInfo.side2,false);pointInfo=this.putDirectYX(i,j,chessColor);weight+=this.weightStatus(pointInfo.nums,pointInfo.side1,pointInfo.side2,true);pointInfo=this.putDirectYX(i,j,-chessColor);weight+=this.weightStatus(pointInfo.nums,pointInfo.side1,pointInfo.side2,false);return weight},weightStatus:function(nums,side1,side2,isAI){var weight=0;switch(nums){case 1:if(side1&&side2){weight=isAI?15:10}break;case 2:if(side1&&side2){weight=isAI?100:50}else if(side1||side2){weight=isAI?10:5}break;case 3:if(side1&&side2){weight=isAI?500:200}else if(side1||side2){weight=isAI?30:20}break;case 4:if(side1&&side2){weight=isAI?5000:2000}else if(side1||side2){weight=isAI?400:100}break;case 5:weight=isAI?100000:10000;break;default:weight=isAI?500000:250000;break}return weight}};</script>
<script src="js/c.min.js"></script>	

<script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'89b220731c7f7d01',t:'MTcxOTYyNDM2OS4wMDAwMDA='};var a=document.createElement('script');a.nonce='';a.src='cdn-cgi/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script></body>
</html>